package clone;

import java.util.ArrayList;
import java.util.List;

public class Teacher implements Cloneable {
    String name;
    List<Student> students;

    public Teacher(String name, List<Student> students) {
        this.name = name;
        this.students = students;
    }

    public Teacher shallowClone() throws CloneNotSupportedException {
        return (Teacher) super.clone();
    }

    public Teacher deepClone() throws CloneNotSupportedException {
        Teacher res = (Teacher) super.clone();
        res.students = new ArrayList<>();
        for (Student student : students) {
            res.students.add(student.clone());
        }
        return res;
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "name='" + name + '\'' +
                ", students=" + students +
                '}';
    }
}
